package teaching.io;

import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;

import javax.swing.JOptionPane;

public class CreateRamdomFile {
  private static final int NUMBER_RECORD = 100;

  private void Createile() {
    File file = new File("d:/emp.dat");
    RandomAccessEmployeeRecord employee = new RandomAccessEmployeeRecord();
    RandomAccessFile randomAccessFile = null;
    try {
      randomAccessFile = new RandomAccessFile(file, "rw");
      for (int i = 0; i < NUMBER_RECORD; i++) {
        employee.write(randomAccessFile);
      }
      System.out.println("ok");
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      try {
        randomAccessFile.close();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }

  public static void main(String[] args) {
    CreateRamdomFile app = new CreateRamdomFile();
    app.Createile();
  }
}
